package com.youbang.bsMgr.user.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.youbang.bsMgr.user.model.UserEntity;


@Component
public class UserDao {
    @Autowired
    private UserMapper userMapper;
    
    public UserEntity queryEntity(Long id) throws Exception {
        UserEntity entity = userMapper.queryEntity(id);
        if(entity ==null){
            return new UserEntity();
        }
        return entity;
    }

    public UserEntity queryEntityByLoginId(String loginId) throws Exception {
        UserEntity entity = userMapper.queryEntityByLoginId(loginId);
        if(entity ==null){
            return new UserEntity();
        }
        return entity;
    }

    public PageInfo queryList(Integer page, Integer pageSize) throws Exception {
        if(page!= null && pageSize!= null){
            PageHelper.startPage(page, pageSize);
        }
        List<UserEntity> users = userMapper.queryList();
        return new PageInfo(users);
    }
}
